home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Toolbox
/
Visual Basic Toolbox (P.I.E.)(1996).ISO
/
listbox
/
filler
/
fillconl.cls
< prev
next >
Wrap
Text File
|
1995-11-22
|
2KB
|
101 lines
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
END
Attribute VB_Name = "ControlFill"
Attribute VB_Creatable = True
Attribute VB_Exposed = False
'Purpose:
' This class is used to fill eather a Standard combobox or Listbox
' with a recordset that is fed to it through property settings.
'Properties:
' "SourceControl" is used to pass ControlFill the Object reference
' of the control to be filled.
' Usage;
' Dim Fill as ControlFill
' Dim Rs as recordset
' Set Fill = New ControlFill
' Fill.SourceControl = Combo1
' "SourceRS" is used to set the recordset property of ControlFill.
' Set this property to any recordset that you like.
' Usage;
' Fill.SourceRs = Rs
' "SourceField" is used to set which field you would like to display
' in the control.
' Usage;
' Fill.SourceField = "MyField"
'Methods:
' "FillControl" is used to fill the control.
' Usage;
' "set other properties first"
' Fill.FillControl
'
'Writen by Michael Lee
'Internet michael.lee@execnet.com
'Compuserve 75720,1221
Option Explicit
Private SourceTable As Recordset
Private SourceFld As String
Private ControlType As Object
Private MyControl As Control
Public Function FillControl() As Boolean
'This function will fill the Combobox or Listbox
'from the control tables. Returns true if no errors
'are reported.
SourceTable.MoveFirst
On Error GoTo ClassError
If TypeOf MyControl Is ComboBox Then 'Check what control type was recieved.
Do Until SourceTable.EOF
MyControl.AddItem SourceTable(SourceFld)
SourceTable.MoveNext
Loop
FillControl = True
ElseIf TypeOf MyControl Is ListBox Then
Do Until SourceTable.EOF
MyControl.AddItem SourceTable(SourceFld)
SourceTable.MoveNext
Loop
FillControl = True
Else
FillControl = False
End If
SourceTable.Close 'Close Recordset. Delete this line if you want to
' keep recordset active.
Exit Function
ClassError:
MsgBox Err.Description
End Function
Public Property Let SourceControl(Source As Object)
Set MyControl = Source
End Property
Public Property Let SourceField(Source As String)
SourceFld = Source
End Property
Public Property Let SourceRS(Source As Recordset)
Set SourceTable = Source
End Property
Private Sub Class_Initialize()
End Sub